/* ====================================================================
 * (#)Header: WebServiceTest.java
 * (#)Revision: 
 * (#)Date Created: 22-Mar-08 12:47:15 AM
 * (#)Created By: Karol Wozniak
 * ====================================================================
 *
 * Copyright (c) 2007 karolak .  All rights reserved.
 *
 * ====================================================================
 * 
 * The software application represented here is the sole property of 
 * karolak. Its unauthorized utilization is expressly prohibited.
 * 
 * ====================================================================
 */
package com.karolak;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;

import javax.xml.namespace.QName;
import javax.xml.ws.Service;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.karolak.entity.Person;
import com.karolak.ws.EntityWebServiceSei;

/**
 * <code>WebServiceTest</code> is used to ....
 * 
 * @author <a href="mailto:kwozniak@hotmail.com">Karol Wozniak</a>
 */
public class EntityWebServiceImplIT {

	@Test
	public void testSelectPerson() throws MalformedURLException {
		System.out.println("hello  test");
		URL wsdlURL = new URL("http://localhost:8080/karolak-ws-cxf/EntityWebService?wsdl");
		// URL wsdlURL = new
		// URL("file:///C:/Documents and Settings/WOZNIK2/dev/workspaces/main/_tempWs/src/main/resources/webService.wsdl");
		QName SERVICE_NAME = new QName("http://ws.karolak.com/", "EntityWebService");
		Service service = Service.create(wsdlURL, SERVICE_NAME);
		EntityWebServiceSei webService = service.getPort(EntityWebServiceSei.class);
		long start = System.currentTimeMillis();
		for (int i = 0; i < 1; i++) {
			List<Person> list = webService.selectPerson();
		}
		long end = System.currentTimeMillis();
		long duration = end - start;
		// List<Person> list = personService.select();
		System.out.println("Result:" + duration);
	}

	@Test
	public void testSelectPersonSpring() throws MalformedURLException {
		ApplicationContext context = new ClassPathXmlApplicationContext("clientContext.xml");
		EntityWebServiceSei webService = (EntityWebServiceSei) context.getBean("webServiceSei");
		long start = System.currentTimeMillis();
		for (int i = 0; i < 2; i++) {
			List<Person> list = webService.selectPerson();
			// System.out.println("Result " + i +" :" + list);
		}
		long end = System.currentTimeMillis();
		long duration = end - start;
		// List<Person> list = personService.select();
		System.out.println("Result:" + duration);
	}

	//@Test
	public void testSelectPersonJms() throws MalformedURLException {
		ApplicationContext context = new ClassPathXmlApplicationContext("clientContext.xml");
		EntityWebServiceSei webService = (EntityWebServiceSei) context.getBean("webServiceSeiJms");
		long start = System.currentTimeMillis();
		for (int i = 0; i < 1; i++) {
			List<Person> list = webService.selectPerson();
		}
		long end = System.currentTimeMillis();
		long duration = end - start;
		System.out.println("Result:" + duration);
	}
}
